import React, { Component } from 'react'
import Header from '../../components/Header'
import {getBannerList} from '../../api/home'
import { Swiper, Image } from 'antd-mobile'
import './index.scss'



export default class index extends Component {

  state = {
    bannerList: []
  }

  componentDidMount(){
    getBannerList().then(res => {
      // console.log(res.data);
      this.setState({
        bannerList: res.data
      })
    })
  }

  render() {
    return (
      <div className='box'>
        <Header title='首页' />
      <div className='content'>
        <Swiper className='my-swiper' autoplay loop>
          {
            this.state.bannerList && this.state.bannerList.map(item => {
              return (<Swiper.Item key={item.bannerid}>
                <Image src={item.img} />
              </Swiper.Item>)
            })
          }
        </Swiper>
      </div>
    </div>
    )
  }
}
